home *** CD-ROM | disk | FTP | other *** search
/ IRIX 6.3 Development Libraries / SGI IRIX 6.3 Development Libraries.iso / dist6.3 / gl_dev.idb / usr / share / src / OpenGL / teach / glc / test1.c.z / test1.c
Encoding:
C/C++ Source or Header  |  1996-12-06  |  1.5 KB  |  88 lines

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <math.h>
  5. #include <GL/gl.h>
  6. #include <GL/glc.h>
  7. #include <GL/glut.h>
  8.  
  9.  
  10. GLuint contextID;
  11.  
  12.  
  13. void Init(void)
  14. {
  15.  
  16.     if ((contextID = glcGenContext()) == 0) {
  17.     printf("Died at glcGenContext\n");
  18.     exit(1);
  19.     }
  20.  
  21.     glcContext(contextID);
  22.     if (glcGetError() != GL_NO_ERROR) {
  23.     printf("Died at glcContext\n");
  24.     exit(1);
  25.     }
  26.  
  27.     glcRenderStyle(GLC_TRIANGLE);
  28.  
  29.     glClearColor(0.0, 0.0, 0.0, 0.0);
  30. }
  31.  
  32. void Reshape(int width, int height)
  33. {
  34.  
  35.     glViewport(0, 0, width, height);
  36.  
  37.     glMatrixMode(GL_PROJECTION);
  38.     glLoadIdentity();
  39.     glOrtho(0.0, (double)width, 0.0, (double)height, -10000.0, 10000.0);
  40.     glMatrixMode(GL_MODELVIEW);
  41. }
  42.  
  43. void Key(unsigned char key, int x, int y)
  44. {
  45.     int i;
  46.     const char *face;
  47.  
  48.     switch (key) {
  49.     case 27:
  50.         glcDeleteContext(contextID);
  51.         exit(1);
  52.     }
  53. }
  54.  
  55. void Display(void)
  56. {
  57.  
  58.     glClear(GL_COLOR_BUFFER_BIT);
  59.  
  60.     glPushMatrix();
  61.     glTranslatef(30.0, 100.0, 0.0);
  62.     glScalef(40.0, 40.0, 1.0);
  63.     glColor3f(0.0, 1.0, 0.0);
  64.     glcRenderString("Hello World!");
  65.     glPopMatrix();
  66.  
  67.     if (glcGetError() != GL_NO_ERROR) {
  68.     printf("Got a GLC error\n");
  69.     exit(1);
  70.     }
  71.  
  72.     glutSwapBuffers();
  73. }
  74.  
  75. void main(int argc, char **argv)
  76. {
  77.  
  78.     glutInitWindowSize(300, 300);
  79.     glutInit(&argc, argv);
  80.     glutInitDisplayMode(GLUT_RGB|GLUT_DOUBLE);
  81.     glutCreateWindow("glc test");
  82.     Init();
  83.     glutDisplayFunc(Display);
  84.     glutReshapeFunc(Reshape);
  85.     glutKeyboardFunc(Key);
  86.     glutMainLoop();
  87. }
  88.